package com.qzw.demo.service.entity;

import com.qzw.common.service.BaseEntity;
import com.qzw.common.util.GeneratorNote;
import lombok.Data;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @author: 屈子威
 * @create: 2020-07-14
 * @description:
 **/
@Entity
@DynamicInsert
@DynamicUpdate
@Data
public class DmOrder extends BaseEntity<Integer> {
    @GeneratorNote("订单号")
    @Column(nullable = false,unique = true)
    private String orderNo;

    @GeneratorNote("交易数量")
    @ColumnDefault("1")
    private BigDecimal quantity;

    @GeneratorNote("总金额")
    private BigDecimal amount;

    @GeneratorNote("用户ID")
    @Column(insertable = false,updatable = false)
    private Integer userId;

    @GeneratorNote("商品ID")
    @Column(insertable = false,updatable = false)
    private Integer shopId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "userId")
    private DmUser dmUser;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "shopId")
    private DmShop dmShop;

    @Version
    private Long version;
}
